package com.free.front.controller.brand;

import javax.servlet.http.HttpServletRequest;

import com.deco.domain.vo.brand.BrandStoryVo;
import com.free.common.vo.ResultModel;
import com.free.front.bf.brand.ActivityReportBf;
import com.free.front.bf.brand.BrandStoryBf;
import com.free.front.controller.BaseController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Controller
public class BrandController extends BaseController {
    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/

    @Autowired
    private ActivityReportBf reportBf;

    @Autowired
    private BrandStoryBf brandStoryBf;
    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/

    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/

    @RequestMapping(value = "/activity_init.json")
    @ResponseBody
    public ResultModel getActivityReportInit(){
        return ResultModel.success(reportBf.initData());
    }

    @RequestMapping(value = "/activity_year.json")
    @ResponseBody
    public ResultModel getActivityReportYearInfo(String year){
        return ResultModel.success(reportBf.getYearListInfo(year));
    }

    @RequestMapping(value = "/activity_detail.json")
    @ResponseBody
    public ResultModel getActivityReportDetail(Long id){
        return ResultModel.success(reportBf.detailInfo(id));
    }
    

    /**
     * 品牌故事
     * 
     * @param request
     * @return
     */
    @RequestMapping("/brandStory.htm")
    public ModelAndView brandStory(HttpServletRequest request) {
        ModelAndView mv = new ModelAndView(getTempleate("/brand/brandStory",request));
        BrandStoryVo storyVo = brandStoryBf.getLatestStory();
        String imgUrl = "/" + storyVo.getImgUrl();
        storyVo.setImgUrl(imgUrl);
        String vedioUrl = "/" + storyVo.getVedioUrl();
        storyVo.setVedioUrl(vedioUrl);
        mv.addObject("brandStory", storyVo);
        return mv;
    }

    /**
     * 活动报道
     * 
     * @param request
     * @return
     */
    @RequestMapping("/activity.htm")
    public String activity(HttpServletRequest request) {
    	 return getTempleate("/brand/activity",request);
    }
    
    /**
     * 活动详情
     * 
     * @param request
     * @return
     */
    @RequestMapping("/activityDetail.htm")
    public String activityDetail(HttpServletRequest request, Long id) {
    	 return getTempleate("/brand/activityDetail",request);
    }
    
    /**
     * 联系我们
     * 
     * @param request
     * @return
     */
    @RequestMapping("/about.htm")
    public String about(HttpServletRequest request) {
    	 return getTempleate("/brand/about",request);
    }
    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
